package org.sradon.service.impl;

import org.sradon.dao.DoubleDao;
import org.sradon.dao.GoodsDao;
import org.sradon.dao.impl.DoubleDaoImpl2;
import org.sradon.dao.impl.DoubleDaoImpl3;
import org.sradon.mySpring.anno.di.Autowired;
import org.sradon.mySpring.anno.di.Qualifier;
import org.sradon.mySpring.anno.ioc.Service;
import org.sradon.service.GoodsService;

import javax.annotation.Resource;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsDao goodsDao;

    /// Impl3执行 因为@Qualifier按照名称
     @Autowired
     @Qualifier("DDI3")
    /// Impl3执行 因为按照名称
    // @Resource(name = "DDI3")
    /// Impl3执行 因为按照类型
    // @Resource(type = DoubleDaoImpl3.class)
    /// Impl2执行 因为按照类型
    // @Resource(type = DoubleDaoImpl2.class)
    /// Impl1执行 有@Parimary
    // @Resource
    private DoubleDao doubleDao;    // 会注入Impl3

    @Override
    public void getGoodsById() {
        System.out.println("*** GoodsService被执行了: ");
        goodsDao.getGoodsById(1);
        doubleDao.run();
    }
}
